-
Notifications
You must be signed in to change notification settings - Fork 15.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bazel: Bump java source and target language level to java 8 #6711
Bazel: Bump java source and target language level to java 8 #6711
Conversation
@@ -654,8 +654,8 @@ java_library( | |||
javacopts = select({ | |||
"//:jdk9": ["--add-modules=jdk.unsupported"], | |||
"//conditions:default": [ | |||
"-source 7", | |||
"-target 7", | |||
"-source 8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that we are going to drop Java 7 support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we would like to drop Java 7 support soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is: Java 11 doesn't support building with language level 7. Moreover, Bazel switched to using JDK 11 internally, and the console is spammed with spurious warning messages:
warning: -parameters is not supported for target value 1.7. Use 1.8 or later.
in many issue trackers: [1], [2].
But I see now, that Maven build doing something similar in java/pom.xml
so that this PR is incomplete:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
But personally, I don't care about Maven. Would it be an option to remove Java 7 support for Bazel driven build, so to say merge this PR as is, but let Maven world untouched? That way all bazel friends in the wild wouldn't see these annoying warnings, for each and every java_proto_library
rules in their own and transitive dependencies BUILD files.
For example in Gerrit Code Review, I am seeing these warnings dozen times:
- During the build of protobuf itself (would be fixed in this PR)
- During the build of rules_closure (transitive dependency of gerrit)
- During the build of gerrit itself, should be fixed with this CL in Bazel itself
[1] bazelbuild/bazel#8772
[2] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. We don't want existing JDK 7 users to be stuck in an old version of Protobuf. But since you are saying Java 11 doesn't support building language level 7 and Bazel switched to using JDK 11, does this mean there are currently no Bazel users who are using JDK 7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize, my bad. Java 11, 13 and even 14 version still support java language level 7 (byte code major version 51).
This issue is entirely a Bazel bug (incompatibility of two Java compiler options) and should be be fixed in Bazel instead. Sorry for the noise.
Having said that, you should consider to discontinue Java 7 language level support in future Protobuf releases.
The most recent JDK 13 and upcoming JDK 14 release already issue this warning. JDK 13:
$ cat A.java
class A {}
$ ~/pgm/jdk-13/bin/javac -source 7 -target 7 -parameters A.java
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: -parameters is not supported for target value 7. Use 8 or later.
JDK 14:
$ ~/pgm/jdk-14/bin/javac -source 7 -target 7 -parameters A.java
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: -parameters is not supported for target value 7. Use 8 or later.
FTR: the proper fix in Bazel project is here. |
This is a workaround to suppress annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstrea, that was rejected: [2]. moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably neeed to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and writing the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] protocolbuffers/protobuf#6711 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] protocolbuffers/protobuf#6711 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
//CC @Yannic. This is the rejected attempt to drop the Java 7 (declared as dead dozen years ago) compatibility from Protobuf library. And that's why patching |
There's already a special-case for JDK 9 (which, btw, results in not setting javacopts = select({
# TODO: I think this should actually be "//java:jdk7": [], "//java:jdk8": [], "//conditions:default": ["--add-modules=jdk.unsupported"] so >= JDK 9 sets --add-modules=jdk.unsupported.
"//java:jdk9": ["--add-modules=jdk.unsupported"],
"//conditions:default": [],
}) + select({
"//java:jdk7": [
"-source 7",
"-source 7",
],
"//conditions:default": [
"-source 8",
"-source 8",
],
}) |
There no such thing as JDK9. It's dead and discontinued, so nobody really care about that configuration option.
There is no such thing as jdk7 in Bazel: It is the dead horse and was dropped years ago:
The whole point with backwards compatibility in JDK17_MAJOR_VERSION = 51 is created even if Java 8, 11, 13 and 14 and newer are used. I'm curious, what Bazel driven project is using Protobuf and still relies on JDK 7? Can someone point me to a one single Open Source project who is doing that? If none is doing/using that feature, can we re-consider dropping JDK7 compatibility in Protobuf project in Bazel driven build tool chain only, but keep it in Gradle and Apache Maven? |
I uploaded a new PR: #7306. |
Then let's get rid of that configuration.
So all this is about is binary compatibility of |
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
No description provided.